package com.base2.webshop.server.dao;

import java.util.List;

import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;


import com.base2.webshop.server.entities.ShopDetails;

public class ShopDetailsDao extends AbstractDao{
	
	private static int pageSize = 3;
	public ShopDetailsDao(){
		
	}
	
	@SuppressWarnings("unchecked")
	public List<ShopDetails> findAllShopDetails(){
		return jpaTemplate.find("from ShopDetails");
	}
	
	public ShopDetails findShopDetails(Long id) {
		return jpaTemplate.find(ShopDetails.class,id);
	}  
	
	public void persist(){
		jpaTemplate.persist(this);
	}
	
	public void remove(){
		jpaTemplate.remove(this);
	}
//	
//	public static List getData(int pageNumber) {
//	   SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
//	   Session session = sessionFactory.getCurrentSession();
//	   List result = null;
//	   try {
//	     session.beginTransaction();
//	     Query query = session.createQuery("from ShopDetails");
//	      query = query.setFirstResult(pageSize * (pageNumber - 1));
//	      query.setMaxResults(pageSize);
//	     result = query.list();
//	     session.getTransaction().commit();
//	   } catch (Exception e) {
//	     e.printStackTrace();
//	   }
//	   return result;
//	}

}
